﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using BEGDC.CC.BL.Common.Query;
using BEGDC.CC.BL.Common;

namespace BEGDC.CC.Web.UserControls.EV
{
	/// <summary>
	/// Summary description for SearchCustomer.
	/// </summary>
	public class SearchCustomer : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Button btnSubmit;
        protected System.Web.UI.WebControls.Button ibtnClose;
		protected System.Web.UI.WebControls.Label lblCustomerName;
		protected System.Web.UI.WebControls.Label lblCustomerNameCalue;
		protected System.Web.UI.WebControls.Label lblResult;
		protected System.Web.UI.WebControls.ListBox lstboxResult;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
			if( !IsPostBack )
			{
				GetCustomerName();
				this.btnSubmit.Attributes["onclick"] = "javascript:OnSubmit();";
                this.ibtnClose.Attributes["onclick"] = "javascript:OnClose();";
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void GetCustomerName()
		{
			string name = Request.QueryString["CustomerName"];
			this.lblCustomerNameCalue.Text = name;
			
			IQuery queryService = BEGDC.Utility.Castle.AppContainer.Instance[ServiceConst.QueryService] as IQuery;

			this.lstboxResult.DataSource = queryService.GetCustomersByName( name );
			this.lstboxResult.DataTextField = "Name";
			this.lstboxResult.DataValueField = "CustomerInfoID";
			this.lstboxResult.DataBind();

		}
	}
}
